home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / CGI::Fast.z / CGI::Fast
Encoding:
Text File  |  1998-10-30  |  6.4 KB  |  199 lines

  1.  
  2.  
  3.  
  4. CCCCGGGGIIII::::::::FFFFaaaasssstttt((((3333))))                                                      CCCCGGGGIIII::::::::FFFFaaaasssstttt((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      CGI::Fast - CGI Interface for Fast CGI
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use CGI::Fast qw(:standard);
  13.          $COUNTER = 0;
  14.          while (new CGI::Fast) {
  15.              print header;
  16.              print start_html("Fast CGI Rocks");
  17.              print
  18.                  h1("Fast CGI Rocks"),
  19.                  "Invocation number ",b($COUNTER++),
  20.                  " PID ",b($$),".",
  21.                  hr;
  22.              print end_html;
  23.          }
  24.  
  25.  
  26. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  27.      CGI::Fast is a subclass of the CGI object created by CGI.pm.  It is
  28.      specialized to work well with the Open Market FastCGI standard, which
  29.      greatly speeds up CGI scripts by turning them into persistently running
  30.      server processes.  Scripts that perform time-consuming initialization
  31.      processes, such as loading large modules or opening persistent database
  32.      connections, will see large performance improvements.
  33.  
  34. OOOOTTTTHHHHEEEERRRR PPPPIIIIEEEECCCCEEEESSSS OOOOFFFF TTTTHHHHEEEE PPPPUUUUZZZZZZZZLLLLEEEE
  35.      In order to use CGI::Fast you'll need a FastCGI-enabled Web server.  Open
  36.      Market's server is FastCGI-savvy.  There are also freely redistributable
  37.      FastCGI modules for NCSA httpd 1.5 and Apache.  FastCGI-enabling modules
  38.      for Microsoft Internet Information Server and Netscape Communications
  39.      Server have been announced.
  40.  
  41.      In addition, you'll need a version of the Perl interpreter that has been
  42.      linked with the FastCGI I/O library.  Precompiled binaries are available
  43.      for several platforms, including DEC Alpha, HP-UX and SPARC/Solaris, or
  44.      you can rebuild Perl from source with patches provided in the FastCGI
  45.      developer's kit.  The FastCGI Perl interpreter can be used in place of
  46.      your normal Perl without ill consequences.
  47.  
  48.      You can find FastCGI modules for Apache and NCSA httpd, precompiled Perl
  49.      interpreters, and the FastCGI developer's kit all at URL:
  50.  
  51.        http://www.fastcgi.com/
  52.  
  53.  
  54. WWWWRRRRIIIITTTTIIIINNNNGGGG FFFFAAAASSSSTTTTCCCCGGGGIIII PPPPEEEERRRRLLLL SSSSCCCCRRRRIIIIPPPPTTTTSSSS
  55.      FastCGI scripts are persistent: one or more copies of the script are
  56.      started up when the server initializes, and stay around until the server
  57.      exits or they die a natural death.  After performing whatever one-time
  58.      initialization it needs, the script enters a loop waiting for incoming
  59.      connections, processing the request, and waiting some more.
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. CCCCGGGGIIII::::::::FFFFaaaasssstttt((((3333))))                                                      CCCCGGGGIIII::::::::FFFFaaaasssstttt((((3333))))
  71.  
  72.  
  73.  
  74.      A typical FastCGI script will look like this:
  75.  
  76.          #!/usr/local/bin/perl    # must be a FastCGI version of perl!
  77.          use CGI::Fast;
  78.          &do_some_initialization();
  79.          while ($q = new CGI::Fast) {
  80.              &process_request($q);
  81.          }
  82.  
  83.      Each time there's a new request, CGI::Fast returns a CGI object to your
  84.      loop.  The rest of the time your script waits in the call to _n_e_w().  When
  85.      the server requests that your script be terminated, _n_e_w() will return
  86.      undef.  You can of course exit earlier if you choose.  A new version of
  87.      the script will be respawned to take its place (this may be necessary in
  88.      order to avoid Perl memory leaks in long-running scripts).
  89.  
  90.      CGI.pm's default CGI object mode also works.  Just modify the loop this
  91.      way:
  92.  
  93.          while (new CGI::Fast) {
  94.              &process_request;
  95.          }
  96.  
  97.      Calls to _h_e_a_d_e_r(), _s_t_a_r_t__f_o_r_m(), etc. will all operate on the current
  98.      request.
  99.  
  100. IIIINNNNSSSSTTTTAAAALLLLLLLLIIIINNNNGGGG FFFFAAAASSSSTTTTCCCCGGGGIIII SSSSCCCCRRRRIIIIPPPPTTTTSSSS
  101.      See the FastCGI developer's kit documentation for full details.  On the
  102.      Apache server, the following line must be added to srm.conf:
  103.  
  104.          AddType application/x-httpd-fcgi .fcgi
  105.  
  106.      FastCGI scripts must end in the extension .fcgi.  For each script you
  107.      install, you must add something like the following to srm.conf:
  108.  
  109.         AppClass /usr/etc/httpd/fcgi-bin/file_upload.fcgi -processes 2
  110.  
  111.      This instructs Apache to launch two copies of file_upload.fcgi at startup
  112.      time.
  113.  
  114. UUUUSSSSIIIINNNNGGGG FFFFAAAASSSSTTTTCCCCGGGGIIII SSSSCCCCRRRRIIIIPPPPTTTTSSSS AAAASSSS CCCCGGGGIIII SSSSCCCCRRRRIIIIPPPPTTTTSSSS
  115.      Any script that works correctly as a FastCGI script will also work
  116.      correctly when installed as a vanilla CGI script.  However it will not
  117.      see any performance benefit.
  118.  
  119. CCCCAAAAVVVVEEEEAAAATTTTSSSS
  120.      I haven't tested this very much.
  121.  
  122. AAAAUUUUTTTTHHHHOOOORRRR IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  123.      be used and modified freely, but I do request that this copyright notice
  124.      remain attached to the file.  You may modify this module as you wish, but
  125.      if you redistribute a modified version, please attach a note listing the
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. CCCCGGGGIIII::::::::FFFFaaaasssstttt((((3333))))                                                      CCCCGGGGIIII::::::::FFFFaaaasssstttt((((3333))))
  137.  
  138.  
  139.  
  140.      modifications you have made.
  141.  
  142.      Address bug reports and comments to:  lstein@genome.wi.mit.edu
  143.  
  144. BBBBUUUUGGGGSSSS
  145.      This section intentionally left blank.
  146.  
  147. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  148.      the _C_G_I::_C_a_r_p manpage, the _C_G_I manpage
  149.  
  150.      =cut
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.